package com.jews.framework.easyexcel.utils;

import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import org.apache.poi.ss.usermodel.*;

/**
 * Excel样式
 *
 * @author JewsChen
 * @date 2023/2/2 17:48
 */
public class EasyExcelStyleStrategy {

    private EasyExcelStyleStrategy() {
    }

    public static HorizontalCellStyleStrategy getExportDefaultStyle() {
        //头部单元格样式
        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
        //内容单元格样式
        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
        //头部字体样式
        WriteFont headWriteFontStyle = new WriteFont();
        //内容字体样式
        WriteFont contentWriteFontStyle = new WriteFont();
        headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        headWriteCellStyle.setBorderBottom(BorderStyle.THIN);
        headWriteCellStyle.setBorderTop(BorderStyle.THIN);
        headWriteCellStyle.setBorderLeft(BorderStyle.THIN);
        headWriteCellStyle.setBorderRight(BorderStyle.THIN);
        headWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
        headWriteCellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
        headWriteCellStyle.setWrapped(false);
        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
        contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
        contentWriteCellStyle.setWrapped(false);
        headWriteFontStyle.setBold(true);
        headWriteFontStyle.setFontHeightInPoints((short) 10);
        headWriteFontStyle.setColor(IndexedColors.RED.getIndex());
        contentWriteFontStyle.setBold(false);
        contentWriteFontStyle.setFontHeightInPoints((short) 10);
        headWriteCellStyle.setWriteFont(headWriteFontStyle);
        contentWriteCellStyle.setWriteFont(contentWriteFontStyle);
        return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
    }
}
